package com.uzai.console.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.uzai.console.dto.dy.dyorder.DyFindUnReceicedDto;
import com.uzai.console.dto.groupsendjob.GroupSendJobConditionOrderDto;
import com.uzai.console.dto.locallive.mtorder.*;
import com.uzai.console.entity.DyOrder;
import com.uzai.console.entity.MtOrder;
import com.uzai.console.vo.locallive.mtorder.MtOrderReportVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public interface MtOrderMapper {
    int deleteById(@Param("id") Long id, @Param("merId") Long merId);

    int deleteByParam(@Param("query") MtOrderQuery query);

    int insert(MtOrder record);

    int insertSelective(MtOrder record);

    MtOrder selectById(@Param("id") Long id, @Param("merId") Long merId);

    MtOrder selectByChildOrderNo(@Param("childOrderNo") String childOrderNo, @Param("merId") Long merId);
    
    int updateByIdSelective(MtOrder record);

    int updateById(MtOrder record);

    int updateStatus(MtOrder record);

    /**
     * 查询7天前未收货的订单
     * @param dyFindUnReceicedDto
     * @return
     */
    ArrayList<MtOrder> findUnReceivedList(MtFindUnReceicedDto dyFindUnReceicedDto);

    /**
     * 查询7天前冻结的订单
     * @param dyFindUnReceicedDto
     * @return
     */
    ArrayList<MtOrder> findFreezedList(MtFindUnReceicedDto dyFindUnReceicedDto);

    /**
     * 分页查询
     * @param page
     * @param query
     * @return
     */
    ArrayList<MtOrder> findByList(Page<MtOrder> page, @Param("query") MtOrderQuery query);

    /**
     * 查询所有
     * @param query
     * @return
     */
    ArrayList<MtOrder> findByList(@Param("query") MtOrderQuery query);

    /**
     * 查询淘宝订单统计信息
     * @param query
     * @return
     */
    MtOrderReportVo findMtOrderRepot(@Param("query") MtOrderQuery query);

    /**
     * 解绑用户
     * @param
     * @return
     */
    Integer unbindUser(MtOrderUnbindUserDto mtOrderUnbindUserDto);

    /**
     * 绑定用户
     * @param
     * @return
     */
    Integer bindUser(MtOrderBindUserDto mtOrderBindUserDto);

    /**
     * 修改解冻时间
     * @param
     * @return
     */
    Integer updateThawTime(MtOrderThawTimeDto mtOrderThawTimeDto);

    /**
     * 批量替换机器人信息
     * @param merId
     * @return
     */
    int batchUpdateDeviceInfo(@Param("oldDeviceUniqueId") Long oldDeviceUniqueId, @Param("newDeviceUniqueId") Long newDeviceUniqueId, @Param("merId") Long merId);

    /**
     * 将订单状态从付款完成更新到订单结算
     *
     * @param endTime
     * @param userId
     * @param merId
     */
    int updateStatusPayCompleteToSettle(@Param("startTime") Integer startTime, @Param("endTime") Integer endTime, @Param("userId") Long userId, @Param("merId") Long merId,
                                        @Param("status") Integer status, @Param("sourceStatus") List<Integer> sourceStatus);

    /**
     * 将旧会员的订单合并到新会员身上
     *
     * @param userIdOld
     * @param userIdNew
     * @param merId
     */
    int mtOrderMerge(@Param("userIdOld") Long userIdOld, @Param("userIdNew") Long userIdNew, @Param("merId") Long merId);

    List<MtOrder> selectExistsOrderUserIdWithCondition(@Param("condition") GroupSendJobConditionOrderDto conditionOrder);
}